Repository navigation
Conversation
|
💡 Needs an owner decision on the new public field
Diff-only review at |
|
Two quick clarifications for the maintainer call:
|
868b13f to
3823bd2
Compare
|
💡 The new
Reviewed at 3823bd2 (diff only, not built). |
Expose a `dragging: bool` field on `TextSelectionEvent` (and `TextViewSelectionEvent` / JS `onSelectionChange`) that is `true` while a pointer or selection-handle drag is actively extending a non-empty selection and flips to `false` once the drag ends or the selection clears. This allows applications anchoring floating action bars or popovers to `pageBounds` to defer showing the overlay until the user finishes dragging instead of flickering or jumping under the cursor. Contributed by the author from https://github.com/apache/maka (#7504) under NSH's Apache-2.0 license.
3823bd2 to
06aef46
Compare
Summary
Expose
dragging: boolonTextSelectionEvent(andTextViewSelectionEvent/ JSonSelectionChange) so applications anchoring floating action bars or popovers topageBoundscan defer showing them until the user finishes dragging instead of flickering or jumping under the cursor.draggingistruewhile an active pointer or selection-handle drag is extending a non-empty selection (!text.is_empty()), then flips tofalseonce the drag ends (pointer up, cancel, window deactivation, or active handle dismissal) or the selection clears.nsh-testing), including:draggingalongside text, bounds, and endpoints so releasing a drag emitsdragging: falseeven when the selected text and box are unchanged.text.is_empty() => !dragginginvariant across every backend (including empty-copyTextattachments).selectable={false}teardown on macOS/Linux, window-scoped deactivation cancel on GPUI (both mainAppViewand secondaryWindowView), split-touch / handle-dismiss single-source-of-truth tracking on Android + JNIeventMapkey interning, and primary-pointer /.nsh-areadrag ownership on Web.draggingtofalseso listeners always receive a boolean.selection_downignoring nestedInputdrags without affecting programmaticref.selectAll(), andHeadless::done()flushing queued events once on error exit so trailing release errors stay attributed to the drag step.Public API
nsh-core): Addedpub dragging: booltoTextSelectionEvent(already#[non_exhaustive], defaults tofalse).nsh-base): Addedpub dragging: booltoTextViewSelectionEvent(already#[non_exhaustive], defaults tofalse) and plumbede.dragginginTextView.dragging: booleantoonSelectionChangeon selectable<View>and<TextView>(crates/nsh-core/src/js/host.rs,TextViewSelectionEventJsObjectderive).text-selection.mdandtext-view.md.Breaking Changes
None. Both
TextSelectionEventandTextViewSelectionEventare already#[non_exhaustive]and deriveDefault; JS listeners receive an additionaldragging: booleanproperty (defaulting tofalsefor any payload omitting it).Verification
cargo clippy -p nsh-core -p nsh-js -p nsh-base -p nsh-testing -p nsh-platform-macos -p nsh-platform-tui --features nsh-platform-macos/dev --tests -- -D warnings;NSH_TEXT_VIEW_SELECTION_CHECK_ONLY=1 cargo test -p nsh-platform-macos --test native -- --ignored(asserts real AppKitdragging: true -> falseacrossLeftMouseDown/LeftMouseDragged/LeftMouseUp).cargo test -p nsh-core --lib selected_text,public_api_is_typed;cargo test -p nsh-js --lib declarations(20/20);cargo test -p nsh-base --test base text_view_selection_change_forwards_dragging_state;cargo test -p nsh-testing --lib selection_drag_reports_dragging_until_release(drag_and_hold/drop_held, nestedInput,ref.selectAll());cargo test -p nsh-testing --features bundle --test testing select(5/5);cargo test -p nsh-platform-tui --test tui a_selection_area_reports_dragging_until_mouse_up.node --test crates/nsh-platform-web/web/nsh.test.mjs(201/201, exercising realpointerDown/areaSelects/editable/textAt/areaGap/areaOf, concurrent pointer types, andpointerUp);cargo check --target wasm32-unknown-unknown -p nsh-platform-web --tests.cargo clippy --manifest-path crates/gpui/Cargo.toml -p nsh-platform-gpui --features runtime-shaders -- -D warnings;cargo clippy --target aarch64-apple-ios -p nsh-platform-ios --features embed,dev --no-deps -- -D warnings.cargo clippy -p nsh-platform-linux --tests -- -D warnings;xvfb-run -a cargo test -p nsh-platform-linux --lib selectable_view(3/3).cargo clippy -p nsh-platform-windows --tests -- -D warnings;cargo test -p nsh-platform-windows --lib selectable_view(2/2).tests/compat/cases/base/base-selectable-view.tsxandscript.txt(stricte.dragging === falsecheck on omitted payloads +true -> falseon both<View selectable>and<TextView selectable>).Original contribution authored by @M4n5ter and contributed directly under NSH's Apache-2.0 license.